﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Diagnostics;
using System.IO;
using System.Text;
using Jd.ArchitectTest.AbcCalc;

namespace Jd.ArchitectTest.AbcClient
{
	class Program
	{
		static void Main( string[] args )
		{
			Stopwatch watch = new Stopwatch();
			watch.Start();
			IAbcClient client = AbcClientFactory.GetAbcClient();
			client.Start();
#if !DEBUG
			using ( StreamReader reader = new StreamReader( ConfigurationManager.AppSettings["AbcClient_InputFile"] ) )
			{
				long x;
				string num;
				while ( reader.Peek() > -1 )
				{
					num = reader.ReadLine();
					if ( long.TryParse( num, out x ) )
					{
						client.InputX( x );
					}
				}
				reader.Close();
			}
#else
			for ( int i = 1; i <= 10000; i++ )
			{
				client.InputX( i );
			}
#endif
			BigInt sum = client.GetSum();
			Console.WriteLine( string.Format( "总和: {0}", sum ) );
			client.Stop();
			watch.Stop();
			Console.WriteLine( string.Format( "运行时间: {0}毫秒", watch.ElapsedMilliseconds ) );
			Console.ReadLine();
		}
	}
}
